package idea.think.adapter;

import idea.think.IdeaAll;
import idea.think.R;
import idea.think.vo.AllIdea;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AllIdeaAdapter extends ArrayAdapter<AllIdea> {
	private IdeaAll iAll;
	
	public AllIdeaAdapter(Context context, List<AllIdea> objects) {
		super(context, 0, objects);
		iAll = (IdeaAll)context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v;
		final ViewHolder holder;
		LayoutInflater inflater = iAll.getLayoutInflater();
		
		if(convertView == null){
			v = inflater.inflate(R.layout.all_idea_buttonview, null);				
			holder = new ViewHolder();
			holder.allIdeaBtn01 = (TextView) v.findViewById(R.id.all_idea_Btn01);
			holder.allIdeaBtn02 = (TextView) v.findViewById(R.id.all_idea_Btn02);
			holder.allIdeaBtn03 = (TextView) v.findViewById(R.id.all_idea_Btn03);
			v.setTag(holder);								
		}else{
			v = convertView;
			holder = (ViewHolder)v.getTag();
		}
		
		AllIdea aIdea = getItem(position);
		holder.allIdeaBtn01.setText(aIdea.getAllIdea1());
		holder.allIdeaBtn01.setWidth(100);
		holder.allIdeaBtn02.setText(aIdea.getAllIdea2());
		holder.allIdeaBtn02.setWidth(100);
		holder.allIdeaBtn03.setText(aIdea.getAllIdea3());
		holder.allIdeaBtn03.setWidth(100);							
					
		return v;
	}
}
